//
//  HSYBaseViewController+Keyboard.m
//  高仿暴走斗图
//
//  Created by key on 16/6/15.
//  Copyright © 2016年 huangsongyao. All rights reserved.
//

#import "HSYBaseViewController+Keyboard.h"

@implementation HSYBaseViewController (Keyboard)

- (RACSignal *)rac_kvoToKeyboardWillShowByObject:(id)object {
    
    return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
        
        [[[[NSNotificationCenter defaultCenter] rac_addObserverForName:UIKeyboardWillShowNotification object:object] deliverOn:[RACScheduler mainThreadScheduler]] subscribeNext:^(NSNotification *notification) {
            
            [subscriber sendNext:notification];
        }];
        return nil;
    }];
}

- (RACSignal *)rac_kvoToKeyboardDidHideByObject:(id)object {
 
    return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
        
        [[[[NSNotificationCenter defaultCenter] rac_addObserverForName:UIKeyboardDidHideNotification object:object] deliverOn:[RACScheduler mainThreadScheduler]] subscribeNext:^(NSNotification *notification) {
            
            [subscriber sendNext:notification];
        }];
        return nil;
    }];
}


- (RACSignal *)rac_kvoToKeyboardDidChangeByObject:(id)object {
    
    return [RACSignal createSignal:^RACDisposable *(id<RACSubscriber> subscriber) {
        
        [[[NSNotificationCenter defaultCenter] rac_addObserverForName:UIKeyboardDidChangeFrameNotification object:nil]
         subscribeNext:^(NSNotification *notification) {
             
             [subscriber sendNext:notification];
         }];
        return nil;
    }];
}

- (void)rac_removeKVOByKeyboardForName:(NSString *)name object:(id)object {

    [[NSNotificationCenter defaultCenter] removeObserver:self name:name object:object];
    
}


@end
